﻿#ifndef MEASURESPEC_H
#define MEASURESPEC_H

#include <QDialog>
#include <QDockWidget>
#include <QtCore/QVariant>
#include <QtWidgets/QAction>
#include <QtWidgets/QApplication>
#include <QtWidgets/QButtonGroup>
#include <QtWidgets/QDialog>
#include <QtWidgets/QGridLayout>
#include <QtWidgets/QGroupBox>
#include <QtWidgets/QHeaderView>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
#include <QtWidgets/QRadioButton>
#include <QtWidgets/QSpacerItem>
#include <QtWidgets/QSpinBox>
#include <QtWidgets/QTextEdit>
#include <QtWidgets/QToolButton>
#include <QtWidgets/QWidget>
#include <QImage>
#include "Sqlite.h"
#include "CheckPosition.h"
#include <gsl/gsl_fit.h>

namespace Ui {
class MeasureSpec;
}
class B3MainWindow;

//这个类是放到 MeasureSpecDockWidget 里面的
class MeasureSpecWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MeasureSpecWidget(QWidget *parent = 0, B3MainWindow *win = 0);
    ~MeasureSpecWidget();
    void clean();
signals:
    void closeDockWidget();
    void goToXYZ(double x, double y, double z, double speed);  // 20190929 append, zdz

private slots:
    void on_toolButton_findDir_clicked();
    void on_pushButton_createDataBase_clicked();
    void on_pushButton_GetStartPos_clicked(); //获取起点坐标
    void on_pushButton_GetEndPos_clicked(); //获取终点坐标
    void on_pushButton_Write_clicked();
    void on_comboBox_MeasureID_currentIndexChanged(int index);
    void on_lineEdit_CL_editingFinished();
//    void on_pushButton_Goto_clicked();  // 20190929 append, zdz
    void on_pushButton_GotoSrtart_clicked();// 运动到起点
    void on_pushButton_GotoEnd_clicked(); //运动到终点

private:
    Ui::MeasureSpec *ui;

    int m_measureNumber;
    QString m_sqlPath;
    QString m_panelName;

    Sqlite * m_sqlite;
    int m_index;
    MeasureSpecInfo m_measureSpecInfo;
    QList<MeasureSpecInfo> m_allMeasureSpecInfo;

    B3MainWindow *m_win;
    double m_startScale;
    int m_startLen;
    int m_startIntensity_top;
    int m_startIntensity_bottom;
    int m_startExpoureTime;
    double m_endScale;
    int m_endLen;
    int m_endIntensity_top;
    int m_endIntensity_bottom;
    int m_endExpoureTime;

    void setData(QString sqlPath, QString panelName, int measureNumber, QString description);
    bool createDataBase();
    bool writeMeasureSpec();
    int checkImage(QImage img);

    /* 20190929 */
    double m_posX;
    double m_posY;
    double m_posZ;
};

#endif // MEASURESPEC_H
